#include "Game.h"
#include "XMLParser.h"


using namespace std;



/**
 * Deletes all items loaded in the Game
 * @param void
 * @return void
 */
void Game::freeItemsInformation()
{
	if (m_items.size() == 0)
	{
		cout << "No item information available." << endl;
	}
	else
	{
		for (unsigned int i = 0; i < m_items.size(); ++i)
		{
			Item* item;
			item = m_items[i];
			delete item;
		}
		m_items.resize(0);
	}
}


/**
 * Loads all Item information for the game.
 * @see GetConfig::GetConfig()
 * @see GetConfig::addATTROption()
 * @see GetConfig::readClassConfigFile
 * @param void
 * @return void
 */
void Game::loadItemsInformation()
{
	XMLParser appConfig(GAME_LOADCONFIG_ITEM_ROOTELEM, GAME_LOADCONFIG_ITEM_FIRSTELEM);

	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR1);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR2);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR3);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR4);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR5);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR6);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR7);
	appConfig.addATTROption(GAME_LOADCONFIG_ITEM_ATTR8);
	appConfig.readItemConfigFile(GAME_LOADCONFIG_ITEM_FILENAME, m_items);
}


/**
 * Prints out information about all the Items in the Game
 * @see Class::print()
 * @param void
 * @return void
 */
void Game::showItemsInformation()
{
	if (m_items.size() == 0)
	{
		cout << "No monsters information available." << endl;
	}
	else
	{
		cout << "==================" << endl;
		for (unsigned int i = 0; i < m_items.size(); ++i)
		{
			m_items[i]->print();
		}
		cout << "==================" << endl;
	}
}